//app.js
const urlAdd = require('utils/config').urlAdd;
App({
  onLaunch: function () {

    // this.globalData.stuCode = wx.getStorageSync('stuCode')

    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
  },
    globalData: {
      token:'',
      openId: null,      
      tabBar: {
        "backgroundColor": "#ffffff",
        "color": "#333333",
        "selectedColor": "#30a1db",
        "list": [
          {
            "pagePath": "/pages/index/index",
            "text": "首页",
            "iconPath": "../../images/shouye_white.png",
            "selectedIconPath": "../../images/shouye_blue.png"
          },
          {
            "pagePath": "/pages/xunika/xunika",
            "isSpecial": true,
            "text": "虚拟卡",
            "iconPath": "../../images/erweima.png",
            "selectedIconPath": "../../images/erweima.png"
          },
          
          {
            "pagePath": "/pages/mine/mine",
            "text": "账号",
            "iconPath": "../../images/zhanghao_white.png",
            "selectedIconPath": "../../images/zhanghao_blue.png"
          }
        ]
      }
    },
    //自定义导航栏
    editTabbar: function () {
      //隐藏系统tabbar
      wx.hideTabBar();
      let tabbar = this.globalData.tabBar;
      let currentPages = getCurrentPages();
      let _this = currentPages[currentPages.length - 1];
      let pagePath = _this.route;
      (pagePath.indexOf('/') != 0) && (pagePath = '/' + pagePath);
      for (let i in tabbar.list) {
        tabbar.list[i].selected = false;
        (tabbar.list[i].pagePath == pagePath) && (tabbar.list[i].selected = true);
      }
      _this.setData({
        tabbar: tabbar

      });
      
    },


    /** 出路后台返回富文本框 HTML标签 */
    convertHtmlToText: function convertHtmlToText(inputText) {
      var returnText = "" + inputText;
      returnText = returnText.replace(/<\/div>/ig, '\r\n');
      returnText = returnText.replace(/<\/li>/ig, '\r\n');
      returnText = returnText.replace(/<li>/ig, ' * ');
      returnText = returnText.replace(/<\/ul>/ig, '\r\n');
      //-- remove BR tags and replace them with line break
      returnText = returnText.replace(/<br\s*[\/]?>/gi, "\r\n");
     
      //-- remove P and A tags but preserve what's inside of them
      returnText=returnText.replace(/<p.*?>/gi, "\r\n");
      returnText=returnText.replace(/<a.*href="(.*?)".*>(.*?)<\/a>/gi, " $2 ($1)");
     
      //-- remove all inside SCRIPT and STYLE tags
      returnText=returnText.replace(/<script.*>[\w\W]{1,}(.*?)[\w\W]{1,}<\/script>/gi, "");
      returnText=returnText.replace(/<style.*>[\w\W]{1,}(.*?)[\w\W]{1,}<\/style>/gi, "");
      //-- remove all else
      returnText=returnText.replace(/<(?:.|\s)*?>/g, "");
     
      //-- get rid of more than 2 multiple line breaks:
      returnText=returnText.replace(/(?:(?:\r\n|\r|\n)\s*){2,}/gim, "\r\n\r\n");
     
      //-- get rid of more than 2 spaces:
      returnText = returnText.replace(/ +(?= )/g,'');
     
      //-- get rid of html-encoded characters:
      returnText=returnText.replace(/ /gi," ");
      returnText=returnText.replace(/&/gi,"&");
      returnText=returnText.replace(/"/gi,'"');
      returnText=returnText.replace(/</gi,'<');
      returnText=returnText.replace(/>/gi,'>');
      
         return returnText;
        },


    

})